var express = require('express');
var getRouter = express.Router();
var postRouter = express.Router();
var axios = require('axios')
var rootApi = "http://112.74.105.17:20003/question-bank"
/* GET users listing. */
getRouter.get('/examById', function (req, res, next) {

    var thisApi = '/examById'
    var getPaperId = JSON.stringify(req.query.paperId)
    getPaperId = getPaperId.substring(1, (getPaperId.length - 1))

    axios.post("http://localhost:3000" + thisApi, {
        paperId: getPaperId
    })
        .then(function (response) {
            res.send(response.data)
        })
        .catch(function (error) {
            console.log(error);
        });

});

postRouter.post('/examById', function (req, res, next) {
    var thisApi = '/wx/exam/paper-stem/'
    var paperId = JSON.stringify(req.body.paperId)
    paperId = paperId.substring(1, (paperId.length - 1))
    axios.post(rootApi + thisApi + paperId, {
    })
        .then(function (response) {
            console.log("success!")
            res.send(response.data)
        })
        .catch(function (error) {
            console.log(error);
        });
});

exports.get = getRouter;
exports.post = postRouter;
// module.exports = router;
